<template>
  <div class="login-wrap">
    <div class="ms-login">
      <div class="ms-title">匿名检测系统</div>
      <el-form
          :model="param"
          :rules="rules"
          ref="login"
          label-width="0px"
          class="ms-content loading"
      >
        <el-form-item prop="userName">
          <el-input v-model="param.userName" placeholder="用户名">

          </el-input>
        </el-form-item>
        <el-form-item prop="passWord">
          <el-input
              type="passWord"
              placeholder="密码"
              v-model="param.passWord"
              show-password
              @keyup.enter="submitForm()"
          >

          </el-input>
        </el-form-item>
        <div class="login-btn">
          <el-button type="primary" @click="submitForm()">登 录</el-button>
        </div>
        <!--        <p class="login-tips">前台：-->
        <!--          <el-link type="primary" href="http://www.azhou.cloud/repair/login.html">前往用户端</el-link>-->
        <!--        </p>-->
      </el-form>
    </div>
  </div>
</template>

<script>
import {util} from '../utils/index';

export default {
  mixins: [util],
  data() {
    return {
      param: {
        userName: "",
        passWord: "",
      },
      rules: {
        userName: [
          {required: true, message: "请输入用户名", trigger: "blur"},
        ],
        passWord: [{required: true, message: "请输入密码", trigger: "blur"}],
      },
    };
  },
  created() {
    this.$store.commit("clearTags");
  },
  methods: {
    submitForm() {
      this.$refs.login.validate((valid) => {
        if (valid) {
          var date = {};
          date.userName = this.param.userName;
          date.passWord = this.param.passWord;
          this.notify("登录成功");
          this.$router.push("/main");
          // this.$basePostRequest("/login", date)
          //     .then((res) => {
          //       this.notify("登录成功");
          //       this.setUserMsg(res);
          //       this.$router.push("/main");
          //     })
          //     .catch(err => {
          //     });
        } else {
          this.notify("请输入账号和密码", "error");
          return false;
        }
      });
    },
  },
};
</script>

<style scoped>
.login-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  background-size: 100%;
}

.ms-title {
  width: 100%;
  line-height: 50px;
  text-align: center;
  font-size: 20px;
  color: black;
  font-weight: bold;
  border-bottom: 1px solid #ddd;
}

.ms-login {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 350px;
  margin: -190px 0 0 -175px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.3);
  overflow: hidden;

}

.ms-content {
  padding: 30px 30px;
}

.login-btn {
  text-align: center;
}

.login-btn button {
  width: 100%;
  height: 36px;
  margin-bottom: 10px;
}

.login-tips {
  font-size: 12px;
  line-height: 30px;
  color: black;
}
</style>
